<?php
Box::$description["List"] = "Container for a list of boxes";
/**
*A configurable list of boxes
*@author Willy Gardiol <willy@gardiol.org>
*@version 1.0
*@package Boxes
*@subpackage Box_List
*/
class Box_List extends Box
{
	public function __construct( $title  )
	{
		parent::__construct( $title, "inline", "box:List/BoxList" );
	}

	protected function PostInitialize()
	{
		$this->AddEditTab( "box:List/BoxListEdit",
							I18N("Configure list"),
							I18N("Save list of boxes"),
							"SaveBoxList" );
		$this->SetStorage(array("vertical" => true) );
	}

	protected function SaveBoxList( $request )
	{
		$v = Core::PostVar("orientation", "v", "string");
		$items = Core::PostVar("items", false, "sequence");
		$this->Set("vertical", $v == "v" ) && $request->SetReload(true);
		if ( $items !== false )
		{
			$cur_list = $this->GetChildren();
			foreach ( $cur_list as $k => $v )
				$this->RemoveChild( $k );
			$n = 0;
			foreach ( $items as $k )
				$this->SetChild( $n++, $k );
			$request->SetReload(true);
		}
		echo I18N("Box saved");
	}

}
?>